package GUI;

import Logica.Surgery;

import java.awt.Dimension;

import java.awt.Rectangle;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

public class AgregarCirugia extends JFrame {
  private JLabel jLabel1 = new JLabel();
  private JLabel jLabel2 = new JLabel();
  private JLabel jLabel3 = new JLabel();
  private JButton jButton1 = new JButton();
  private JFormattedTextField jFormattedTextField1 = new JFormattedTextField();
  private JFormattedTextField jFormattedTextField2 = new JFormattedTextField();
  private JFormattedTextField jFormattedTextField3 = new JFormattedTextField();

  public AgregarCirugia() {
    try {
      jbInit();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  private void jbInit() throws Exception {
    this.getContentPane().setLayout( null );
    this.setSize( new Dimension(400, 300) );
    jLabel1.setText("Sala");
    jLabel1.setBounds(new Rectangle(25, 70, 85, 25));
    jLabel2.setText("Staff Number");
    jLabel2.setBounds(new Rectangle(25, 115, 85, 25));
    jLabel3.setText("Appointment number");
    jLabel3.setBounds(new Rectangle(25, 160, 125, 25));
    jButton1.setText("Guardar");
    jButton1.setBounds(new Rectangle(275, 205, 85, 35));
    jButton1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          jButton1_actionPerformed(e);
        }
      });
    jFormattedTextField1.setBounds(new Rectangle(175, 70, 165, 30));
    jFormattedTextField2.setBounds(new Rectangle(175, 115, 165, 30));
    jFormattedTextField3.setBounds(new Rectangle(175, 160, 165, 30));
    this.getContentPane().add(jFormattedTextField3, null);
    this.getContentPane().add(jFormattedTextField2, null);
    this.getContentPane().add(jFormattedTextField1, null);
    this.getContentPane().add(jButton1, null);
    this.getContentPane().add(jLabel3, null);
    this.getContentPane().add(jLabel2, null);
    this.getContentPane().add(jLabel1, null);
  }

  private void jButton1_actionPerformed(ActionEvent e) 
  {
    Surgery a = new Surgery();
    if(a.creaSurgey(jFormattedTextField1.getText().toString(), jFormattedTextField2.getText().toString(), jFormattedTextField3.getText().toString() ))
      {
        JOptionPane.showMessageDialog(null, "Creado", "La cirugia ha sido creada", JOptionPane.INFORMATION_MESSAGE); 
        }
      else{
          JOptionPane.showMessageDialog(null, "No Creado",
                                        "La cirugia  no ha sido creada",
                                        JOptionPane.ERROR_MESSAGE);
        }
  }
}
